package com.sgb.kjwl.view.ui.adapter.self;

import android.content.Context;


import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.businessmanagement.CompanyEntity;
import com.sgb.kjwl.view.ui.activity.self.EnterpriseInformationActivity;
import com.sgb.kjwl.view.widget.RoundImageView;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.io.File;
import java.util.List;

/*
企业列表适配器
 */
public class EnterprisesListAdapter extends BaseRecycleAdapter<CompanyEntity> {
    private LinearLayout layout_corporate;
    private RoundImageView mImgAuth;

    public EnterprisesListAdapter(Context context, List<CompanyEntity> list) {
        super(context, R.layout.adapter_enterpriseslistadapter_item, list);
    }

    @Override
    public void convert(ItemViewHolder holder, CompanyEntity companyEntity) {
        holder.setBinding(BR.viewModel, companyEntity);
        layout_corporate = holder.itemView.findViewById(R.id.layout_corporate);
        mImgAuth = holder.itemView.findViewById(R.id.img_auth);
        if (companyEntity.getStatus() == 1 || companyEntity.getStatus() == 2) {
            mImgAuth.setVisibility(View.VISIBLE);
            if (companyEntity.getStatus() == 1)
                Glide.with(context).load(context.getResources().getDrawable(R.mipmap.icon_shz_com)).into(mImgAuth);
            if (companyEntity.getStatus() == 2)
                Glide.with(context).load(context.getResources().getDrawable(R.mipmap.icon_yjr_com)).into(mImgAuth);
        } else {
            mImgAuth.setImageResource(R.drawable.icon_auth_fail);
        }
        layout_corporate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //跳转到企业详情界面（带公司具体参数）
                if (companyEntity.getStatus() == 2)
                    EnterpriseInformationActivity.start(context, companyEntity);
            }
        });
    }
}